﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;


namespace HA.ModFlow.Domain.DomainLayer
{
    [Serializable]
    /// <summary>
    /// 用以表示水井
    /// </summary>
    public class Well:MFPointSC, ICloneable
    {

         public Well(int i, int j, int k, int nrows, int ncolumns, int nlayers,int nPeriods)
            : base(i, j, k,nrows,ncolumns,nlayers,nPeriods)
        {
            this._rechargeRates = new List<double>();



            for (int m = 0; m < nPeriods; m++)
            {
                this._rechargeRates.Add(0);

                
            }

        }

         public Well(int index, int nrows, int ncolumns, int nlayers, int nPeriods)
            : base(index, nrows, ncolumns, nlayers,nPeriods)
        {


            this._rechargeRates = new List<double>();


         

            for (int m = 0; m < nPeriods; m++)
            {
                this._rechargeRates.Add(0);
                
            }

 
        }


        bool _isActive = true;

        public bool IsActive
        {
            get { return _isActive; }
            set { _isActive = value; }
        }



        string _name;

        public string Name
        {
            get { return _name; }
            set
            {
                _name = value;
            }
               
        }

      


        List<double> _rechargeRates=new List<double>();

        public List<double> RechargeRates
        {
            get { return _rechargeRates; }
            set 
            { 
                _rechargeRates = value;
             
            }
        }


        public double FirstRechargeRates
        {
            get
            {

                return this._rechargeRates[0];


            }

            set
            {
                this._rechargeRates[0] = value;


            }

        }


       




        public object Clone()
        {

            Well well =(Well)this.MemberwiseClone();

            well._rechargeRates = new List<double>();

            well._rechargeRates.AddRange(this.RechargeRates);

          

            return well;


        }

        public override void OnResetSperiods(int nPeriods)
        {
            base.OnResetSperiods(nPeriods);

            if (this.NPeriods == nPeriods)
            {
                return;
            }

            if (this.NPeriods < nPeriods)
            {
                int nSub = nPeriods - this.NPeriods;

                for (int i = 0; i < nSub; i++)
                {
                    this.RechargeRates.Add(this.RechargeRates[0]);  
                }
            }

            else
            {
                int nSub = this.NPeriods - nPeriods;
                this.RechargeRates.RemoveRange(nPeriods, nSub);
            }

            this.NPeriods = nPeriods;
        }         

    }
}
